package org.geekbang.thinking.in.spring.ioc.bean.lifecycle;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;

/**
 * Annotation 元信息
 * @author : zjj
 * @date : 2022/2/24 17:33
 */
public class AnnotationBeanDefinitionDemo {
    public static void main(String[] args) {
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        AnnotatedBeanDefinitionReader annotatedBeanDefinitionReader =new AnnotatedBeanDefinitionReader(beanFactory);

        int beforeCount = beanFactory.getBeanDefinitionCount();

        annotatedBeanDefinitionReader.register(AnnotationBeanDefinitionDemo.class);

        int afterCount = beanFactory.getBeanDefinitionCount();

        System.out.println("bean定义个数：" + (afterCount - beforeCount));

        AnnotationBeanDefinitionDemo annotationBeanDefinitionDemo = beanFactory.getBean("annotationBeanDefinitionDemo", AnnotationBeanDefinitionDemo.class);
        System.out.println(annotationBeanDefinitionDemo);


    }
}
